import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';
import 'package:flutter/material.dart';
import 'dart:ui';

class ShareWidget extends StatefulWidget {
  // final String oid;
  final WeChatShareWebPageModel model;
  ShareWidget(this.model);
  // BusinessEditcarPage(this.oid);
  @override
  ShareWidgetState createState() => new ShareWidgetState(this.model);
}

class ShareWidgetState extends State<ShareWidget> {
  WeChatScene scene = WeChatScene.SESSION;
  final WeChatShareWebPageModel model;
  ShareWidgetState(this.model);
  List view_arr = [
    {
      'title': '微信好友',
      'icon': 'resource/images/user/wechat.jpeg',
      'tag': WeChatScene.SESSION
    },
    {
      'title': '朋友圈',
      'icon': 'resource/images/user/wechat1.jpeg',
      'tag': WeChatScene.TIMELINE
    }
  ];
  // String str;
  // Color color;
  // double fontSize;
  // double fontWeight;

  // Nodata(this.str, this.color, this.fontSize, this.fontWeight);

  @override
  Widget build(BuildContext context) {
    return new Container(
      height: 160.0,
      child: new Column(
        children: <Widget>[
          new Padding(
            padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 0.0),
            child: new Container(
              height: 100.0,
              child: new GridView.builder(
                gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    mainAxisSpacing: 1.0,
                    childAspectRatio: 1.0),
                itemBuilder: (BuildContext context, int index) {
                  var item = view_arr[index];
                  return new GestureDetector(
                      onTap: () {
                        //print(item['tag']);
                        Navigator.of(context).pop();
                        var models = WeChatShareWebPageModel(
                          model.webPage,
                          title: model.title,
                          description: model.description,
                          //description: '233',
                          thumbnail: model.thumbnail,
                          scene: item['tag'],
                        );
                        //model.scene = item['tag'];
                        shareToWeChat(models);
                        // setState(() {
                        //   scene = item['tag'];

                        // });

                        //选择检测师
                        // setState(() {
                        //   scene = item['tag'];
                        //   share();
                        // });
                      },
                      child: new Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          new Padding(
                              padding: EdgeInsets.fromLTRB(0.0, 6.0, 0.0, 6.0),
                              child: new Container(
                                  decoration: new BoxDecoration(
                                    // 底色
                                    //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                    borderRadius: new BorderRadius.circular(
                                        25), // 也可控件一边圆角大小
                                  ),
                                  height: 50,
                                  width: 50,
                                  child: ClipRRect(
                                    borderRadius: BorderRadius.circular(25),
                                    child: Image.asset( item['icon']),
                                    // child: FadeInImage.assetNetwork(
                                    //   placeholder: item['icon'],
                                    //   image: '',
                                    //   fit: BoxFit.cover,
                                    // ),
                                  ))),
                          Expanded(child: new Text(item['title']))
                        ],
                      ));
                },
                itemCount: view_arr.length,
              ),
            ),
          ),
          new Container(
            height: 0.5,
            color: Colors.blueGrey,
          ),
          new Center(
            child: new Padding(
              padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
              child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    Navigator.of(context).pop();
                  },
                  child: new Text(
                    '取  消',
                    style:
                        new TextStyle(fontSize: 18.0, color: Colors.blueGrey),
                  )),
            ),
          ),
        ],
      ),
    );
  }
}
